//
// Created by 谢哲 on 2021/4/23.
//

#include <iostream>
#include <string>

using namespace std;

int main() {
    int n;
    cin >> n;

    int max_index = -1;
    string max_val = "";

    for (int i=1; i<=n; ++i) {
        string s;
        cin >> s;
        if (s.length()>max_val.length()) {
            max_index = i;
            max_val = s;
        }
        else if (s.length()==max_val.length()&&s>max_val) {
            max_index = i;
            max_val = s;
        }
    }

    cout << max_index << endl << max_val;

    return 0;
}